package com.hzx.controller;

import com.hzx.OrderItem;
import com.hzx.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserService userService;

    @PostMapping(value = "/login")
    public int login(@RequestParam("name") String name, @RequestParam("password") String password) {
        return userService.login(name, password);
    }

    @PostMapping(value = "/signUp")
    public boolean signUp(@RequestParam("name") String name, @RequestParam("password") String password) {
        return userService.signUp(name, password);
    }

    @GetMapping("/order")
    public OrderItem[] addActivity(@RequestParam("uId") int uId) {
        return userService.searchOrder(uId).toArray(new OrderItem[0]);
    }
}
